package coml.jiyun.hp.mvpextract;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import java.util.ArrayList;
import coml.jiyun.hp.mvpextract.adapter.RlvAdapter;
import coml.jiyun.hp.mvpextract.base.BaseActivity;
import coml.jiyun.hp.mvpextract.bean.NaviBean;
import coml.jiyun.hp.mvpextract.presenter.MainPresenter;
import coml.jiyun.hp.mvpextract.view.MainView;

public class MainActivity extends BaseActivity<MainPresenter> implements MainView {

    private RecyclerView mRlv;
    private RlvAdapter rlvAdapter;

    @Override
    protected void initData() {
        mPresenter.getData();
    }

    @Override
    protected void initView() {
        mRlv = findViewById(R.id.rlv);
        ArrayList<NaviBean.DataBean> dataBeans = new ArrayList<>();
        mRlv.setLayoutManager(new LinearLayoutManager(this));
        rlvAdapter = new RlvAdapter(this, dataBeans);
        mRlv.setAdapter(rlvAdapter);
    }

    @Override
    protected MainPresenter initPresenter() {
        return new MainPresenter();
    }

    @Override
    protected int getlayout() {
        return R.layout.activity_main;
    }

    @Override
    public void setData(NaviBean bean) {
        Log.d("tag","SetData:"+bean.toString());
        rlvAdapter.addData(bean.getData());
    }
}